function handle() {
  let i=0;
  (function run() {
    if (++i <= 30) {
      setTimeout(run, 100);
    }
    console.log(i);
  })()
}

handle()